<extend name="./public/frame.html"/>
<block name="content">
    <style>
        .layui-form-label {
            width: 10%;
        }

        .layui-input-block {
            margin-left: 12%;
        }
    </style>
    <form class="layui-form" autocomplete="off">
    <h2 style="text-align: center;">司机信息</h2>
        <div class="layui-form-item">
            <label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>驾驶员培训课程名称</label>
            <div class="layui-input-inline">
                <input type="text" name="courseName" id="courseName" value="{$data.courseName}" class="layui-input"
                       lay-verify="required">
            </div>
            <div class="layui-form-mid layui-word-aux">字符串 64</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><i
                    style="color:red;font-size: 28px;vertical-align: bottom;">*</i>培训日期</label>
            <div class="layui-input-inline">
                <input type="text" name="courseDate" id="courseDate" value="{$data.courseDate}" class="layui-input date"
                       lay-verify="required">
            </div>
            <div class="layui-form-mid layui-word-aux">yyyyMMdd</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i
                    style="color:red;font-size: 28px;vertical-align: bottom;">*</i>培训开始日期</label>
            <div class="layui-input-inline">
                <input type="text" name="courseStartDate" id="courseStartDate" value="{$data.courseStartDate}" class="layui-input date"
                       lay-verify="required">
            </div>
            <div class="layui-form-mid layui-word-aux">yyyyMMdd</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i
                    style="color:red;font-size: 28px;vertical-align: bottom;">*</i>培训结束日期</label>
            <div class="layui-input-inline">
                <input type="text" name="courseEndDate" id="courseEndDate" value="{$data.courseEndDate}" class="layui-input  date"
                       lay-verify="required">
            </div>
            <div class="layui-form-mid layui-word-aux">yyyyMMdd</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i
                    style="color:red;font-size: 28px;vertical-align: bottom;">*</i>培训时长</label>
            <div class="layui-input-inline">
                <input type="text" name="courseDays" id="courseDays" value="{$data.courseDays}" class="layui-input"
                       lay-verify="required|number" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')">
            </div>
            <div class="layui-form-mid layui-word-aux">整数型 天</div>
        </div>
        <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>网约车经营许可证号</label>-->
        <!--<div class="layui-input-inline">-->
        <!--<input type="text" name="licence" value="{$data.licence}" class="layui-input">-->
        <!--</div>-->
        <!--<div class="layui-form-mid layui-word-aux">网约车经营许可证号</div>-->
        <!--</div>-->
        <input type="hidden" name="driver_id" id="driver_id" value="{$driver_id}">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" id="submits" lay-filter="sub">立即提交</button>
            </div>
        </div>
    </form>
    <script>
        layui.use(['laydate','layer'], function () {
            var laydate = layui.laydate
                , layer = layui.layer;
            ;
            lay('.date').each(function () {
                laydate.render({
                    elem: this
                    , type: 'date'
                    , trigger: 'click'
                    , format: 'yyyyMMdd'
                });
            });

            $('#submits').click(function () {
                var driver_id = $('#driver_id').val(),
                    courseName = $('#courseName').val(),
                    courseDate = $('#courseDate').val(),
                    courseStartDate = $('#courseStartDate').val(),
                    courseEndDate = $('#courseEndDate').val(),
                    courseDays = $("#courseDays").val();

                $.post("/admin/System/jspx_submits", {
                    driver_id: driver_id,
                    courseName: courseName,
                    courseDate: courseDate,
                    courseStartDate: courseStartDate,
                    courseEndDate: courseEndDate,
                    courseDays: courseDays
                }, function (res) {
                    if (res.code === 1) {
                            layer.msg(res.msg,{icon: 6});
                            setTimeout(function () {
                                window.location.reload();
                            },1000);
                            // 向java 提交 交通部接口数据
                            ajax_post_java();
                        } else {
                            layer.msg(res.msg,{icon: 5});
                        }
                    },'json');
                return false;
            });

        });

        function ajax_post_java() {
            var driver_id = $('#driver_id').val(),
                courseName = $('#courseName').val(),
                courseDate = $('#courseDate').val(),
                courseStartDate = $('#courseStartDate').val(),
                courseEndDate = $('#courseEndDate').val(),
                courseDays = $('#courseDays').val();
//            var temp=$(form.data).serialize();

            $.post("/admin/System/ajax_sjpx", {
                driver_id: driver_id,
                courseName: courseName,
                courseDate: courseDate,
                courseStartDate: courseStartDate,
                courseEndDate: courseEndDate,
                courseDays: courseDays
            }, function (res) {
                if (res.code === 1) {
                    console.log(res.msg);
                } else {
                    console.log(res.msg);
                }
            }, 'json');
        }

    </script>
</block>
